/* eslint-disable no-useless-escape */
// 设备类型检测
let wfDevice = {
    isAndroid: false,
    isIos: false,
    isWxapp: false,
    isWeixin: false,
    webView: false,
    isPC: false
}
const ua = navigator.userAgent
// wx.miniProgram.getEnv(function (res) {
//     console.log(res.miniprogram) // true
//     wfDevice.isWxapp = window.__wxjs_environment == 'miniprogram'
//     // console.log('小程序环境')
// })

wfDevice.androidApp = ua.match(/wf_android/)
wfDevice.iosApp = ua.match(/wf_ios/)
wfDevice.android = ua.match(/(Android);?[\s\/]+([\d.]+)?/)
wfDevice.iPad = ua.match(/(iPad).*OS\s([\d_]+)/)
wfDevice.iPod = ua.match(/(iPod)(.*OS\s([\d_]+))?/)
wfDevice.iPhone = !wfDevice.iPod && ua.match(/(iPhone\sOS)\s([\d_]+)/)
wfDevice.isWeixin = ua.toLowerCase().match(/MicroMessenger/i) == "micromessenger"




// Android
if (wfDevice.androidApp) {
    wfDevice.isAndroid = true
    console.log('安卓手机环境')
}
//IOS
if (wfDevice.iosApp && (wfDevice.iPad || wfDevice.iPod || wfDevice.iPhone)) {
    wfDevice.isIos = true
    console.log('IOS坏境')
}
wfDevice.isWebView = wfDevice.isAndroid || wfDevice.isIos


wfDevice.webView = wfDevice.androidApp || wfDevice.iosApp
wfDevice.isPC = !wfDevice.webView && !wfDevice.isWeixin

// PC
if (wfDevice.isWebView) {
    console.log('PC环境');
}
export default wfDevice